/***********************************************************************
* $Id:: cdc_desc.c 211 2011-06-17 21:34:04Z usb06052                          $
*
* Project: USB device ROM Stack test module
*
* Description:
*     USB Communication Device Class User module.
*
***********************************************************************
*   Copyright(C) 2011, NXP Semiconductor
*   All rights reserved.
*
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* products. This software is supplied "AS IS" without any warranties.
* NXP Semiconductors assumes no responsibility or liability for the
* use of the software, conveys no license or title under any patent,
* copyright, or mask work right to the product. NXP Semiconductors
* reserves the right to make changes in the software without
* notification. NXP Semiconductors also make no representation or
* warranty that such application will be suitable for the specified
* use without further testing or modification.
**********************************************************************/
#include <string.h>
#include "mw_usbd.h"
#include "mw_usbd_rom_api.h"
#include "app_usbd_cfg.h"


#ifdef __GNUC__
#define ALIGN4 __attribute__ ((aligned(4)))
#else // Keil
#define ALIGN4 __align(4)
#endif

#define _(c) c, 0

/* USB Standard Device Descriptor */
ALIGN4 const uint8_t VCOM_DeviceDescriptor[] = {
	USB_DEVICE_DESC_SIZE,              /* bLength */
	USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */
	WBVAL(0x0200), /* 2.0 */           /* bcdUSB */
	USB_DEVICE_CLASS_COMMUNICATIONS,   /* bDeviceClass CDC*/
	0x00,                              /* bDeviceSubClass */
	0x00,                              /* bDeviceProtocol */
	USB_MAX_PACKET0,                   /* bMaxPacketSize0 */
	WBVAL(0x1FC9),                     /* idVendor */
	WBVAL(0x0011),                     /* idProduct */
	WBVAL(0x0100), /* 1.00 */          /* bcdDevice */
	0x01,                              /* iManufacturer */
	0x02,                              /* iProduct */
	0x04,                              /* iSerialNumber */
	0x01                               /* bNumConfigurations: one possible configuration*/
};

/* USB Configuration Descriptor */
/*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
ALIGN4 const uint8_t VCOM_ConfigDescriptor[] = {
	/* Configuration 1 */
	USB_CONFIGUARTION_DESC_SIZE,       /* bLength */
	USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
	WBVAL(                             /* wTotalLength */
		1 * USB_CONFIGUARTION_DESC_SIZE +
		1 * USB_INTERFACE_DESC_SIZE     +  /* communication interface */
		0x0013                        +  /* CDC functions */
		1 * USB_ENDPOINT_DESC_SIZE      +  /* interrupt endpoint */
		1 * USB_INTERFACE_DESC_SIZE     +  /* data interface */
		2 * USB_ENDPOINT_DESC_SIZE         /* bulk endpoints */
	),
	0x02,                              /* bNumInterfaces */
	0x01,                              /* bConfigurationValue: 0x01 is used to select this configuration */
	0x00,                              /* iConfiguration: no string to describe this configuration */
	USB_CONFIG_BUS_POWERED /*|*/       /* bmAttributes */
	/* USB_CONFIG_REMOTE_WAKEUP */,
	USB_CONFIG_POWER_MA(100),          /* bMaxPower, device power consumption is 100 mA */
	/* Interface 0, Alternate Setting 0, Communication class interface descriptor */
	USB_INTERFACE_DESC_SIZE,           /* bLength */
	USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
	USB_CDC_CIF_NUM,                   /* bInterfaceNumber: Number of Interface */
	0x00,                              /* bAlternateSetting: Alternate setting */
	0x01,                              /* bNumEndpoints: One endpoint used */
	CDC_COMMUNICATION_INTERFACE_CLASS, /* bInterfaceClass: Communication Interface Class */
	CDC_ABSTRACT_CONTROL_MODEL,        /* bInterfaceSubClass: Abstract Control Model */
	0x00,                              /* bInterfaceProtocol: no protocol used */
	0x03,                              /* iInterface: */
	/* Header Functional Descriptor */
	0x05,                              /* bLength: Endpoint Descriptor size */
	CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
	CDC_HEADER,                        /* bDescriptorSubtype: Header Func Desc */
	WBVAL(CDC_V1_10), /* 1.10 */       /* bcdCDC */
	/* Call Management Functional Descriptor */
	0x05,                              /* bFunctionLength */
	CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
	CDC_CALL_MANAGEMENT,               /* bDescriptorSubtype: Call Management Func Desc */
	0x01,                              /* bmCapabilities: device handles call management */
	0x01,                              /* bDataInterface: CDC data IF ID */
	/* Abstract Control Management Functional Descriptor */
	0x04,                              /* bFunctionLength */
	CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
	CDC_ABSTRACT_CONTROL_MANAGEMENT,   /* bDescriptorSubtype: Abstract Control Management desc */
	0x02,                              /* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */
	/* Union Functional Descriptor */
	0x05,                              /* bFunctionLength */
	CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
	CDC_UNION,                         /* bDescriptorSubtype: Union func desc */
	USB_CDC_CIF_NUM,                   /* bMasterInterface: Communication class interface is master */
	USB_CDC_DIF_NUM,                   /* bSlaveInterface0: Data class interface is slave 0 */
	/* Endpoint 1 Descriptor */	   /* event notification (optional) */
	USB_ENDPOINT_DESC_SIZE,            /* bLength */
	USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
	USB_CDC_EP_INT_IN,                 /* bEndpointAddress */
	USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
	WBVAL(0x0010),                     /* wMaxPacketSize */
	0x02,          /* 2ms */           /* bInterval */
	/* Interface 1, Alternate Setting 0, Data class interface descriptor */
	USB_INTERFACE_DESC_SIZE,           /* bLength */
	USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
	USB_CDC_DIF_NUM,                   /* bInterfaceNumber: Number of Interface */
	0x00,                              /* bAlternateSetting: no alternate setting */
	0x02,                              /* bNumEndpoints: two endpoints used */
	CDC_DATA_INTERFACE_CLASS,          /* bInterfaceClass: Data Interface Class */
	0x00,                              /* bInterfaceSubClass: no subclass available */
	0x00,                              /* bInterfaceProtocol: no protocol used */
	0x03,                              /* iInterface: */
	/* Endpoint, EP3 Bulk Out */
	USB_ENDPOINT_DESC_SIZE,            /* bLength */
	USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
	USB_CDC_EP_BULK_OUT,               /* bEndpointAddress */
	USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
	WBVAL(USB_HS_MAX_BULK_PACKET),     /* wMaxPacketSize */
	0x00,                              /* bInterval: ignore for Bulk transfer */
	/* Endpoint, EP3 Bulk In */
	USB_ENDPOINT_DESC_SIZE,            /* bLength */
	USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
	USB_CDC_EP_BULK_IN,                /* bEndpointAddress */
	USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
	WBVAL(USB_HS_MAX_BULK_PACKET),     /* wMaxPacketSize */
	0x00,                              /* bInterval: ignore for Bulk transfer */
	/* Terminator */
	0                                  /* bLength */
};

